package com.geekchique.runningbuddy.controller;

import com.geekchique.runningbuddy.R;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.Menu.Item;

import com.geekchique.runningbuddy.activity.Calendar;
import com.geekchique.runningbuddy.activity.Stopwatch;
import com.geekchique.runningbuddy.activity.Today;
import com.geekchique.runningbuddy.provider.ActivityID;

public class OptionsMenuImpl implements IOptionsMenu{

	private Activity activity;

	public OptionsMenuImpl(Activity activity) {
		this.activity = activity;
	}

	public void addAllActivitiesToMenu(Menu menu) {
		menu.add(0, ActivityID.STOPCLOCK, R.string.goto_stopwatch);
		menu.add(1, ActivityID.TODAYJOGS, R.string.goto_today);
		menu.add(2, ActivityID.PASTJOGS, R.string.goto_pastjogs);
		menu.add(3, ActivityID.MAKEMAP, R.string.goto_help);
	}

	public void selectItem(Item item) {
		switch (item.getId()) {

	    case ActivityID.STOPCLOCK:
	    	switchToStopClock();
	    	break;

	    case ActivityID.TODAYJOGS:
	    	switchToToday();
	    	break;

	    case ActivityID.PASTJOGS:
	    	switchToPastJogs();
	    	break;

	    }

	}

	private void switchToStopClock() {
	      Intent i = new Intent(activity, Stopwatch.class);
	      activity.startSubActivity(i, ActivityID.STOPCLOCK);
	}

	private void switchToToday() {
	    Intent i = new Intent(activity, Today.class);
	    activity.startSubActivity(i, ActivityID.TODAYJOGS);
	}

	private void switchToPastJogs() {
	    Intent i = new Intent(activity, Calendar.class);
	    activity.startSubActivity(i, ActivityID.PASTJOGS);
	}


}
